package gogo

import (
	"encoding/json"
	"io/ioutil"
	"net/http"
	"os"
)

type RecvJsonStruct struct {
	Online string `json:"online"`
}

func Regist(regist_url string) {
	Log().Info("registing ...")

	resp, err := http.Get(regist_url)
	CheckError(err)

	data, err := ioutil.ReadAll(resp.Body)
	resp.Body.Close()
	CheckError(err)

	var RecvJson RecvJsonStruct
	err = json.Unmarshal(data, &RecvJson)
	CheckError(err)

	if RecvJson.Online != "yes" {
		Log().Info("registing false !")
		os.Exit(1)
	}
}
